(function() {

    var
    $u = juliet.using({
        validationResult : 'juliet.validation.validationResult-0.2',
        Base : 'juliet.validation.validators.Base-0.2'
    }),
    vr = $u('validationResult');

    var RegexClass = function() {

        this.defaultErrorKey = 'validation:regex';

        this.validate = function(value) {
            var cache = this.validationCache;

            if (cache.value === value) {
                return;
            }

            cache.value = value;

            var regex = new RegExp(this.options.template);

            cache.result = (regex.test(value) ? vr.SUCCESS : vr.FAILED);
        };

    };

    RegexClass.prototype = new ($u('Base'))();

    juliet.registerModule('juliet.validation.validators', 'Regex-0.2', RegexClass);

})();
